package com.yohann.designPattern.factory.simpleFactory.factory;

import com.yohann.designPattern.factory.simpleFactory.pizza.CheesePizza;
import com.yohann.designPattern.factory.simpleFactory.pizza.GreekPizza;
import com.yohann.designPattern.factory.simpleFactory.pizza.PepperPizza;
import com.yohann.designPattern.factory.simpleFactory.pizza.Pizza;

/**
 * <p>
 * 简单工厂模式
 * </p>
 *
 * @author Yohann
 * @since 2021/2/1 13:09
 */
public class SimpleFactory {
    public Pizza createPizza(String type) {
        Pizza pizza = null;

        if ("greek".equals(type)) {
            pizza = new GreekPizza();
        } else if ("cheese".equals(type)) {
            pizza = new CheesePizza();
        } else if ("pepper".equals(type)) {
            pizza = new PepperPizza();
        }

        return pizza;
    }
}